package com.tianzj.boot.mvc.repository.system;

import java.util.List;

import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.tianzj.boot.mvc.entity.system.SysRoleMenu;

public interface SysRoleMenuRepository extends JpaRepository<SysRoleMenu, Long>,JpaSpecificationExecutor<SysRoleMenu> {

	@Query(value="select menu_id from sys_role_menu where role_id =?1",nativeQuery=true)
	List<Long> findMenuIdByRoleId(Long roleId);

	@Modifying(clearAutomatically=true)
	@Transactional
	@Query(value="delete from sys_role_menu where role_id =?1",nativeQuery=true)
	void deleteByRoleId(Long roleId);


	List<SysRoleMenu> findByRoleId(Long roleId);

}
